package jmine.tec.services.export.services;

import jmine.tec.di.annotation.Injected;
import jmine.tec.services.annotations.Execution;
import jmine.tec.services.annotations.Output;
import jmine.tec.services.annotations.Parameter;
import jmine.tec.services.annotations.ServiceImplementor;
import jmine.tec.services.api.ActionsEnum;
import jmine.tec.services.api.export.ReferenceMap;
import jmine.tec.services.api.export.ServiceFiller;
import jmine.tec.services.io.ServiceBean;
import bancosys.tec.persist.dao.BaseDAO;
import bancosys.tec.services.export.domain.MockEntity;

@ServiceImplementor(action = ActionsEnum.INCLUIR)
public class MockEntityService implements ServiceFiller<MockEntity> {

    @Execution
    @Output(propertyName = "ID")
    public MockEntity execute(@Injected BaseDAO<MockEntity> dao, @Parameter("Value") String value) {
        MockEntity entity = dao.createBean();
        entity.setValue(value);
        entity.getPersister().save();
        return entity;
    }

    public void fillServiceBean(ServiceBean bean, ReferenceMap referenceMap, MockEntity entity) {
        bean.setName("MockEntity");
        bean.setAction(ActionsEnum.INCLUIR);
        bean.getParameters().put("Value", entity.getValue());
        bean.getParameters().put("ID", referenceMap.addReference(entity, "mock"));
    }
}
